<template>
    <div class="userCenter">
        <div class="breadcrumb-box">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>个人中心</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="center container td-f">
            <left-nav-bar :active="active"></left-nav-bar>
            <div class="right">
                <div class="line-ti">
                    <div>开通月结</div>
                </div>
                <div v-if="status != -1" style="height:20px"></div>
                <el-tag type="info" v-if="status == 0">正在审核中</el-tag>
                <el-tag type="success" v-if="status == 1">月结申请已通过</el-tag>
                <el-tag type="danger" v-if="status == 2">月结申请已拒绝，拒绝原因：{{reason}}</el-tag>
                <div class="input">
                    <div class="input-tit"><span>*</span>公司名称：</div>
                    <el-input v-model="applyInfo.company_name" :readonly="status == 1 || status == 0?true:false" placeholder="请输入内容"></el-input>
                </div>
                <div class="input">
                    <div class="input-tit"><span>*</span>联系人：</div>
                    <el-input v-model="applyInfo.contacts" :readonly="status == 1 || status == 0?true:false" placeholder="请输入内容"></el-input>
                </div>
                <div class="input">
                    <div class="input-tit"><span>*</span>联系方式：</div>
                    <el-input v-model="applyInfo.mobile" :readonly="status == 1 || status == 0?true:false" placeholder="请输入内容"></el-input>
                </div>
                <div class="input">
                    <div class="input-tit"><span>*</span>备注：</div>
                    <el-input v-model="applyInfo.remark" :readonly="status == 1 || status == 0?true:false" type="textarea" placeholder="请输入内容"></el-input>
                </div>
                <div class="input">
                    <div class="input-tit"><span>*</span>月结说明：</div>
                    <el-input v-model="desc" readonly type="textarea"></el-input>
                </div>
                <div class="submit" @click="submit" v-if="status == -1 || status == 2">{{status == 2?'重新提交':"提交"}}</div>
            </div>
        </div>
        <div style="height: 200px"></div>
    </div>
</template>

<script>
import leftNavBar from "@components/leftNavBar";
import { getUser, readMonth, applyMonth } from "@api/user";

export default {
    name: "userCenter",
    data() {
        return {
            loading: false,
            active: 1,
            userInfo: {},
            desc:
                "月结支付是在月终进行，同时在月份发生额总数下面划一条单红线，以便与下月发生额划分清楚。对于本月未发生会计事项的帐户，不进行月结。",
            messageList: [],
            quotaInfo: "",
            orderStatusNum: {},
            applyInfo: {
                company_name: "",
                contacts: "",
                mobile: "",
                remark: "",
                id:''
            },
            status: 6,
            reason: "",
            dialogImageUrl: "",
            dialogVisible: false,
        };
    },
    components: {
        leftNavBar,
    },
    methods: {
        // 请求月结信息
        read() {
            readMonth().then((res) => {
                // if (res.data.company_name) {
                    let {
                        company_name,
                        contacts,
                        mobile,
                        remark,
                        id,
                        status,
                        reason,
                    } = res.data;

                    this.applyInfo.company_name = company_name;
                    this.applyInfo.contacts = contacts;
                    this.applyInfo.mobile = mobile;
                    this.applyInfo.remark = remark;
                    this.applyInfo.id = id;
                    this.status = status;
                    this.reason = reason;
                // }
            });
        },
        submit() {
            let { company_name, contacts, mobile, remark,id } = this.applyInfo;
            if (!company_name) {
                return this.$dialog.toast({ mes: "请填写公司名称" });
            }
            if (!contacts) {
                return this.$dialog.toast({ mes: "请填写联系人" });
            }
            if (!mobile) {
                return this.$dialog.toast({ mes: "请填写手机号" });
            }
            if (!remark) {
                return this.$dialog.toast({ mes: "请填写备注" });
            }
            if(!id){
                delete this.applyInfo.id;
            }
            applyMonth(this.applyInfo)
                .then((res) => {
                    console.log(res);
                    if (res.status == 200) {
                        this.$dialog.toast({ mes: "申请成功" });
                        this.read();
                        return;
                    }
                    this.$dialog.toast({ mes: res.msg });
                })
                .catch((err) => {
                    console.log(err);
                });
        },
    },
    mounted() {
        this.read();
    },
};
</script>
<style >
.el-upload--picture-card {
    width: 88px;
    height: 88px;
    line-height: 88px;
}
.el-upload-list--picture-card .el-upload-list__item {
    width: 88px;
    height: 88px;
}
.el-textarea__inner {
    height: 80px;
    resize: none;
}
</style>
<style scoped  rel="stylesheet/scss" lang="scss" scoped>
$color: #da213d;
.userCenter {
    width: 100%;
    height: 100%;

    .center {
        /*width: 70%;*/
        margin: 0 auto;
        display: flex;

        .right {
            width: 1000px;
            margin-left: 32px;
            /*margin-top: 90px;*/
            .submit {
                width: 230px;
                height: 50px;
                background: #da213d;
                border-radius: 5px;
                font-size: 18px;
                font-weight: bold;
                text-align: center;
                color: #ffffff;
                line-height: 50px;
                margin: 60px 0 0 116px;
                cursor: pointer;
            }
            .input {
                display: flex;
                // align-items: center;
                margin-top: 20px;
                .input-tit {
                    width: 93px;
                    font-size: 15px;
                    color: #333333;
                    line-height: 40px;
                    text-align: right;
                    span {
                        color: #da213d;
                    }
                }
                .el-input {
                    margin-left: 20px;
                    width: 520px;
                }
                .el-textarea {
                    margin-left: 20px;
                    width: 520px;
                }
            }
            .ti-top {
                border: 1px solid #efc2c1;
                border-top-left-radius: 5px;
                border-top-right-radius: 5px;
                .right-top {
                    display: flex;
                    height: 160px;
                    align-items: center;
                    background: url("../../assets/second_icon/center_bg.png")
                        no-repeat;
                    background-size: 100% 100%;
                    position: relative;

                    .left-ava {
                        margin-left: 55px;
                        width: 82px;
                        height: 82px;
                        border-radius: 50%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        background-color: #fff;
                        box-shadow: inset 0 0 5px 1px
                            rgba($color: #000000, $alpha: 0.2);
                        img {
                            width: 74px;
                            height: 74px;
                            border-radius: 50%;
                        }
                    }
                    .detaiult-avatar {
                        margin-left: 55px;
                        width: 99px;
                        height: 99px;
                        border-radius: 50%;
                        background-color: #fff;
                        box-shadow: inset 0 0 5px 1px
                            rgba($color: #000000, $alpha: 0.2);
                        img {
                            width: 66px;
                            height: 66px;
                            margin-left: 10px;
                        }
                    }

                    .right-txt {
                        display: flex;
                        height: 99px;
                        justify-content: center;
                        align-items: center;
                        margin-left: 5px;

                        > div:nth-of-type(1) {
                            color: #ffffff;
                            font-size: 20px;
                            margin-left: 20px;
                            text-align: justify;
                        }

                        > div:nth-of-type(2) {
                            height: 32px;
                            line-height: 32px;
                            padding: 0 20px;
                            text-align: center;
                            margin-left: 20px;
                            background: linear-gradient(
                                270deg,
                                rgba(23, 22, 20, 0.3) 1%,
                                rgba(99, 77, 77, 0.3)
                            );
                            border-radius: 15px;
                            color: rgba(255, 255, 255, 1);
                            font-size: 18px;
                            // margin-top: 19px;
                            small {
                                padding-right: 2px;
                            }
                        }
                    }

                    .set-btn {
                        position: absolute;
                        right: 30px;
                        top: 50%;
                        width: 70px;
                        height: 30px;
                        font-size: 16px;
                        color: #fff;
                        cursor: pointer;
                        border-radius: 8px;
                        border: 1px solid #da213d;
                        background: #da213d;
                        transform: translateY(-50%);
                        transition: all 0.3s;
                    }

                    .set-btn:hover {
                        background: #fff;
                        color: #da213d;
                    }
                }

                .right-list {
                    display: flex;
                    height: 130px;
                    width: 100%;
                    align-items: center;
                    justify-content: space-around;
                    // margin: 0 auto;
                    cursor: pointer;

                    .li {
                        display: flex;
                        flex-direction: column;
                        width: 33.3%;
                        justify-content: center;
                        align-items: center;
                        position: relative;
                        &::before {
                            position: absolute;
                            right: 0;
                            top: 0;
                            bottom: 0;
                            margin: auto 0;
                            content: "";
                            width: 2px;
                            height: 47px;
                            background: #ecdfdd;
                            border-radius: 1px;
                        }
                        > div:nth-of-type(1) {
                            min-width: 25px;
                            height: 25px;
                            line-height: 25px;
                            text-align: center;
                            background-color: $color;
                            color: #ffffff;
                            font-size: 15px;
                            position: absolute;
                            z-index: 2;
                            border-radius: 50%;
                            margin: -40px 0 0 30px;
                        }

                        img {
                            width: 50px;
                            height: 41px;
                            object-fit: contain;
                        }

                        div:nth-of-type(2) {
                            color: rgba(102, 102, 102, 1);
                            font-size: 17px;
                            font-family: MicrosoftYaHei;
                            margin-top: 13px;
                        }
                    }

                    .li:last-child {
                        img {
                            max-width: 54px;
                        }
                        &::before {
                            display: none;
                        }
                    }
                }
            }

            .line-ti {
                width: 100%;
                border-bottom: 3px solid #dbdbdb;
                height: 40px;
                > div {
                    color: #da213d;
                    font-size: 18px;
                    font-family: MicrosoftYaHei-Bold;
                    border-bottom: 3px solid $color;
                    width: 72px;
                    height: 40px;
                    font-weight: bold;
                    line-height: 36px;
                    padding-left: 5px;
                }
            }

            .shop-list {
                .shop-li {
                    padding-bottom: 10px;

                    .top {
                        display: flex;
                        align-content: center;
                        justify-content: space-between;
                        margin: 30px 0 16px 0;

                        .le {
                            display: flex;
                            height: 24px;
                            align-items: center;

                            img {
                                width: 18px;
                                height: 16px;
                            }

                            > div {
                                color: rgba(51, 51, 51, 1);
                                font-size: 17px;
                                font-family: MicrosoftYaHei;
                                padding-left: 12px;
                            }
                        }

                        .ri {
                            > div {
                                color: #999999;
                            }
                        }
                    }

                    .bot {
                        width: 100%;
                        height: 40px;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;

                        .l {
                            display: flex;
                            height: 80px;
                            align-items: center;
                            margin-left: 15px;

                            img {
                                width: 80px;
                                height: 80px;
                            }

                            > div {
                                color: #333333;
                                padding-left: 15px;
                                font-size: 16px;
                                font-weight: 500;
                                width: 500px;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                            }
                        }

                        .r {
                            width: 85px;
                            height: 30px;
                            line-height: 30px;
                            text-align: center;
                            background: $color;
                            color: #3d75af;
                            font-size: 14px;
                            margin-right: 15px;
                            border-radius: 2px;
                            cursor: pointer;
                        }
                    }
                }

                .shop-li:not(:last-child) {
                    border-bottom: 1px solid #dbdbdb;
                }
            }
        }
    }
}
</style>
